package cn.catsdad.dto;

import cn.catsdad.constant.iConstant.IDateFormat;
import cn.catsdad.entity.Department;
import cn.catsdad.util.DateUtil;
import cn.catsdad.vo.TreeNodeVO;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * 部门dto
 *
 * @author xuyonglong
 * @version V1.0 2023/3/29
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Table(name = "tb_auth_department")
public class DepartmentDTO extends Department {


    /**
     * 创建对应的树节点
     *
     * @return 树节点
     */
    public TreeNodeVO initTreeNode() {
        return new TreeNodeVO()
                .setId(getId())
                .setParentId(getParentId())
                .setLabel(getName())
                .setOrderNum(getOrderNum())
                .setExtraValue1(DateUtil.parseStrFromDate(getCreatedTime(), IDateFormat.YYYY_MM_DD_HH_MM_SS))
                .setExtraValue2(getIcon());
    }

}
